package cn.wostore.wxhelper.service;

import android.app.IntentService;
import android.content.Intent;
import cn.wostore.wxhelper.event.WxDbSyncFinishEvent;
import cn.wostore.wxhelper.utils.WxDatabaseWrapper;
import cn.wostore.wxhelper.utils.L;
import io.reactivex.annotations.NonNull;
import org.greenrobot.eventbus.EventBus;

/**
 * Created by Fanghui at 2019-2-1
 */
public class SyncWxDbService extends IntentService {

    private static final String TAG = SyncWxDbService.class.getSimpleName();

    public SyncWxDbService() {
        super("SyncWxDbService");
    }


    @Override
    protected void onHandleIntent(@NonNull Intent intent) {
        syncWxDatabase();
    }


    private void syncWxDatabase() {
        L.d(TAG, "syncWxDatabase");
        WxDatabaseWrapper.getInstance().sync();
        EventBus.getDefault().post(new WxDbSyncFinishEvent());
    }

}
